<?php

namespace app\admin\controller;

use app\AdminBaseController;

class Pub extends AdminBaseController{

    public function upload(){
        if($this->request->isPost()){
            $file = $this->request->file('file');
            $saveFileName = \think\facade\Filesystem::disk('public')->putFile( 'posts', $file);
            $url = '/storage/'.$saveFileName;
            return json(['location'=>$url]);
        } else {
            return json(['errCode'=>1,'msg'=>'失败','data'=>[]]);
        }

    }

}